using EPiServer.Core;

namespace EPiServer.Labs.MobilePack.Site.Units
{
    [DynamicContent.DynamicContentPlugIn(DisplayName = "[MobilePack] Animation Button Link", ViewUrl = "~/modules/MobilePack/units/AnimationLink.ascx", SortIndex=42000)]
    public partial class AnimationLink : UserControlBase
    {
        public string LinkText { get; set; }
        public PageReference InternalLink { get; set; }
        public string ExternalUrl { get; set; }
        public bool Dialog { get; set; }
        public PropertyAnimationDropDown AnimationProperty { get; set; }

        protected bool IsExternal
        {
            get
            {
                if (InternalLink == null) return true;
                if (InternalLink == PageReference.EmptyReference) return true;
                return !MobileBase.IsMobilePage(InternalLink);
            }
        }

        protected string Animation
        {
            get
            {
                return (AnimationProperty == null) ? string.Empty : AnimationProperty.Value as string;
            }
        }

        protected string LinkUrl
        {
            get
            {
                return (string.IsNullOrEmpty(ExternalUrl)) ? DataFactory.Instance.GetPage(InternalLink).LinkURL : ExternalUrl;
            }
        }

        protected string Text
        {
            get
            {
                return (string.IsNullOrEmpty(LinkText)) ? DataFactory.Instance.GetPage(InternalLink).PageName : LinkText;
            }
        }
    }
}